//
//  FuelMonthModel.m
//  carcareIOS
//
//  Created by ileo on 16/4/12.
//  Copyright © 2016年 chezheng. All rights reserved.
//

#import "FuelMonthModel.h"
#import "CalendarMgr.h"


@implementation FuelMonthModel

@end

@implementation FuelRecordModel
-(void)fillModelWithDic:(NSDictionary *)dic
{
    [super fillModelWithDic:dic];
    NSArray * gpsArr = [self.GPS componentsSeparatedByString:@","];
    if (gpsArr.count > 1) {
        self.longitude = gpsArr[0];
        self.latitude = gpsArr[1];
    }
}

-(void)setAMOUNT:(CGFloat)AMOUNT{
    _AMOUNT = AMOUNT;
    self.totalPrice = AMOUNT;
}

-(CGFloat)fuelVol{
    if (_fuelVol == 0) {
        _fuelVol = self.NEWFUEL - self.OLDFUEL;
    }
    return _fuelVol;
}

-(NSString *)cdt{
    if (!_cdt) {
        _cdt = [CALENDARMGR dateStrWithDate:[CALENDARMGR dateWithStr:self.CDT format:yyyy_MM_dd_HH_mm_ss] format:FORMAT];
    }
    return _cdt;
}
- (NSString *)oilMainCdt
{
    if (!_oilMainCdt) {
        _oilMainCdt = [CALENDARMGR dateStrWithDate:[CALENDARMGR dateWithStr:self.CDT format:yyyy_MM_dd_HH_mm_ss] format:@"MM月dd日"];
    }
    return  _oilMainCdt;
}

-(NSString *)uploadCDT{
    if (![self.cdt isNotNil]) {
        return @"";
    }
    return [CALENDARMGR dateStrWithDate:[CALENDARMGR dateWithStr:self.cdt format:FORMAT] format:yyyy_MM_dd_HH_mm_ss];
}

-(NSDictionary *)uploadDic{
    return @{@"fuelVol":@(self.fuelVol),
             @"records":@(self.NEWRECORDS),
             @"cdt":self.uploadCDT,
             @"gasStationName":self.GSTATION_NAME,
             @"newFuelLabel":self.NEWFUELLABEL,
             @"fuelPrice":@(self.FUELPRICE),
             @"id":@(self.ID),
             @"amount":@(self.totalPrice)};
}

-(NSString *)monthKey{
    return [CALENDARMGR dateStrWithDate:[CALENDARMGR dateWithStr:self.cdt format:FORMAT] format:@"yyyy-MM"];
}

@end

